<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.wlcorp.forcazamis.domain.system.Role" %>
<%@ page import="com.wlcorp.forcazamis.sys.permission.PermissionManager" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.wlcorp.forcazamis.sys.permission.PermissionPage" %>
<%@ page import="com.wlcorp.forcazamis.sys.permission.PermissionSub" %>
<%
	Role role = (Role)request.getAttribute("role");
	PermissionManager permissionManager = PermissionManager.getInstance();
	String[] rolePermission = role.getPermissionArray();
	if(null == rolePermission){
		rolePermission = new String[]{};
	}
%>
<html>
<head>
	<title>角色信息更新</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="0">
	<link href="${pageContext.request.contextPath}/css/css.css" rel=stylesheet>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/button_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/form_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/table_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/pagetitle_css.css" type="text/css">
	<script language="javascript" src="${pageContext.request.contextPath}/script/validator.js"></script>
	<script type="text/javascript">
		function doSave(){
			if(!formIsNotEmpty(document.forms["roleForm"])){
				return;
			}
			document.forms["roleForm"].submit();
		}
		function goback(){
			window.location = "${pageContext.request.contextPath}/system/roleManager.do?method=getRoleList";
		}
	</script>
</head>
<body>
<form name="roleForm" method="POST" action="${pageContext.request.contextPath}/system/roleManager.do?method=modifyRole">
<input type="hidden" name="roleId" value="${role.roleId}"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="30">
	<tr> 
	  <td width="22" class="page_titlebar_head">&nbsp;</td>
	  <td class="page_titlebar_bg" width="981">角色编辑</td>
	</tr>
</table>
<table width="80%" class="InputFrameMain" cellspacing="0" cellpadding="0" border="0" height="100" align="center">
  <tr class="InputFrameLine">
  		<td colspan="2" class="table_unfold_titlebar_small_bg">&nbsp;&nbsp;<b>角色基本信息编辑</b></td>
  </tr>
  <tr class="InputFrameLine">
        <td class="table_label" id="roleName_TEXT" nowrap>&nbsp;角色名称</td>
        <td nowrap>&nbsp;<input class="input" type="text" name="roleName" value="${role.roleName}" style="width:150px" maxlength="20"/></td>
  </tr>
  <tr class="InputFrameLine">
        <td class="table_label" nowrap>&nbsp;角色权限</td>
		<td>&nbsp;
			<%
				List permissionPageList = permissionManager.getPermissionPageList();
				for(Iterator pageIter = permissionPageList.iterator();pageIter.hasNext();){
					PermissionPage permissionPage = (PermissionPage)pageIter.next();
			%>
			<div style="float:left;margin-left:20px">
				<table><tr><td nowrap><%=permissionPage.getTitle()%>:<input type="checkbox" name="permissionArray" value="<%=permissionPage.getId()%>" <%if(permissionManager.checkPermission(rolePermission,permissionPage.getId())){out.print("checked");}%>/></td></tr></table></div>&nbsp;
			<%
				List subPermissionList = permissionManager.getSubPermissionList(permissionPage.getId());
				if(null != subPermissionList && subPermissionList.size() > 0){
				for(Iterator subIter = subPermissionList.iterator();subIter.hasNext();){
					PermissionSub permissionSub = (PermissionSub)subIter.next();
			%>
			<div style="float:left;margin-left:20px">
				<table><tr><td nowrap><%=permissionSub.getTitle()%>:<input type="checkbox" name="permissionArray" value="<%=permissionSub.getId()%>" <%if(permissionManager.checkPermission(rolePermission,permissionSub.getId())){out.print("checked");}%>/></td></tr></table></div>&nbsp;
			<%
				}
				}
			}%>
		</td>
  </tr>
  <tr class="InputFrameLine">
  	<td align="center" colspan="4"><input type="button" class="button_common" name="save_button" value="保存" onclick="javascript:doSave()">
  	<input type="button" class="button_common" name="goback_button" value="返回" onclick="javascript:history.go(-1)"></td>
  </tr>
</table>
</form>
${message}
</body>
</html>
